package persistence

import (
	"BookStack/internal/domain/article"
	"BookStack/internal/domain/book"
	"BookStack/internal/domain/category"
	"BookStack/internal/domain/navigation"
	"BookStack/internal/domain/page"
	"BookStack/internal/domain/tag"
	"BookStack/internal/domain/user"
	repository "BookStack/internal/infrastructure/persistence/repository"

	"gorm.io/gorm"
)

// RepositoryFactory 仓储工厂
type RepositoryFactory struct {
	// 用户仓储
	UserRepository user.Repository

	// 文章仓储
	ArticleRepository article.Repository

	// 书籍仓储
	BookRepository       book.BookRepository
	ChapterRepository    book.ChapterRepository
	RecycleBinRepository book.RecycleBinRepository

	// 自定义页面仓储
	PageRepository page.Repository

	// 分类仓储
	CategoryRepository category.Repository

	// 标签仓储
	TagRepository tag.Repository

	// 导航仓储
	NavigationRepository navigation.Repository

	// 文档仓储（待实现）
	// DocumentRepository document.Repository

	// 评论仓储（待实现）
	// CommentRepository comment.Repository
}

// NewRepositoryFactory 创建仓储工厂
func NewRepositoryFactory(db *gorm.DB) *RepositoryFactory {
	return &RepositoryFactory{
		// 初始化用户仓储
		UserRepository: repository.NewUserRepository(db),

		// 初始化文章仓储
		ArticleRepository: repository.NewArticleRepository(db),

		// 初始化书籍仓储
		BookRepository:       repository.NewBookRepository(db),
		ChapterRepository:    repository.NewChapterRepository(db),
		RecycleBinRepository: repository.NewRecycleBinRepository(db),

		// 初始化自定义页面仓储
		PageRepository: repository.NewPageRepository(db),

		// 初始化分类仓储
		CategoryRepository: repository.NewCategoryRepository(db),

		// 初始化标签仓储
		TagRepository: repository.NewTagRepository(db),

		// 初始化导航仓储
		NavigationRepository: repository.NewNavigationRepository(db),

		// 初始化其他仓储（待实现）
		// DocumentRepository: repository.NewDocumentRepository(db),
		// CommentRepository: repository.NewCommentRepository(db),
	}
}
